package 多线程练习;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestCallable {
      public static void main(String[] args) {
            MyThread myThread=new MyThread();
            FutureTask futureTask=new FutureTask(myThread);
            new Thread(futureTask).start();
            try {
                  String str = (String) futureTask.get();
                  System.out.println(str);
            } catch (InterruptedException e) {
                  throw new RuntimeException(e);
            } catch (ExecutionException e) {
                  throw new RuntimeException(e);
            }
      }
}

class MyThread implements Callable<String> {

      @Override
      public String call() throws Exception {
            return getMessage();//返回一个方法，返回的这个方法可以返回字符串
      }

      private String getMessage() {//这个方法可以返回字符串
            return "Gaoal_Project";
      }
}
